import tensorflow as tf

# 导出模型的线程
from PyQt5.QtCore import QThread, pyqtSignal


class OutputTFLiteModelThread(QThread):
    # 传递string类型的参数
    signal = pyqtSignal(str)

    def __init__(self):
        super(OutputTFLiteModelThread, self).__init__()

    def run(self):

        h5_model = tf.keras.models.load_model("models/new_model.h5")
        converter = tf.lite.TFLiteConverter.from_keras_model(h5_model)
        tflite_model = converter.convert()
        open("models/new_model.tflite", "wb").write(tflite_model)

        self.signal.emit(str("保存模型完成"))